#include <bits/stdc++.h>
using namespace std;
const int M = 2e5 + 5;
long long n, a[M], s[M];
int main(){
    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
        s[i] = s[i - 1] + a[i];
    }
    long long ans = 0;
    for (int i = 1; i <= n; i++){
        ans += a[i] * (s[n] - s[i]);
    }
    cout << ans;
    return 0;
}